package com.mingle.iwalk.uploader;

import java.io.File;
import java.io.UnsupportedEncodingException;



public class iWalk {

	private String BaseURL = "http://karakal.3322.org:8888/Idiot" ;//"http://127.0.0.1:8080/MiddleServer/servlet/ServerGetData";
	
	private HttpSend httpSend = new HttpSend();
	
	/**
	 * @return the userid
	 */
	public String getUserid() {
		return httpSend.getUserid();
	}
	/**
	 * @param userid the userid to set
	 */
	public void setUserid(String userid) {
		httpSend.setUserid(userid);
	}
	/**
	 * @return the username
	 */
	public String getUsername() {
		return httpSend.getUsername();
	}
	/**
	 * @param username the username to set
	 */
	public void setUsername(String username) {
		httpSend.setUsername(username);
	}
	/**
	 * @return the userpass
	 */
	public String getUserpass() {
		return httpSend.getUsername();
	}
	/**
	 * @param userpass the userpass to set
	 */
	public void setUserpass(String userpass) {
		httpSend.setUserpass(userpass);
		
	}
	/**
	 * @return the baseURL
	 */
	public String getBaseURL() {
		return BaseURL;
	}
	/**
	 * @param baseURL the baseURL to set
	 */
	public void setBaseURL(String baseURL) {
		BaseURL = baseURL;
	}
	
		
	/**
	 * @param status what the user wants to say
	 * @theme what theme user selected
	 * @return the latest status
	 */
	public Status updateStatus(String theme,String status,int walkId) {
		
		try {
			String statusutf =java.net.URLEncoder.encode(status,"UTF-8");
			return new Status(httpSend.postData(BaseURL,new PostParameter[]{new PostParameter("theme",theme),new PostParameter("status", statusutf),new PostParameter("walkId", walkId)}, true));
			

		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return null;
		}
		
	   	}
	
	 /**
     * Updates the user's status.
     * The text will be trimmed if the length of the text is exceeding 160 characters.
     * <br>This method calls some address
     *
     * @param status    the text of your status update
     * @param latitude  The location's latitude that this iWalk refers to.
     * @param longitude The location's longitude that this iWalk refers to.
     * @return the latest status
     */

	public Status updateStatus(String theme,String status, double latitude, double longitude, int walkId){
				//String statusutf =java.net.URLEncoder.encode(status,"UTF-8");
			return new Status(httpSend.postData(BaseURL,new PostParameter[]{new PostParameter("theme",theme),new PostParameter("status", status),
					new PostParameter("lat", latitude),new PostParameter("long", longitude),new PostParameter("walkId", walkId)}, true));
	}
	
	 /**
     * Updates the user's status.
     * The text will be trimmed if the length of the text is exceeding 160 characters.
     * <br>This method calls some address
     *
     * @param status    the text of your status update
     * @param File  the file want to be uploaded
     * @return the latest status
     */
	public Status updateStatus(String theme,String status, File file, int walkId) {
		return new Status(httpSend.postDataWithFile(BaseURL,new PostParameter[]{new PostParameter("theme",theme),
				new PostParameter("status", status)},file, true));
	}
	
	 /**
     * Updates the user's status.
     * The text will be trimmed if the length of the text is exceeding 160 characters.
     * <br>This method calls some address
     *
     * @param status    the text of your status update
     * @param latitude  The location's latitude that this iWalk refers to.
     * @param longitude The location's longitude that this iWalk refers to.
     * @param File  the file want to be uploaded
     * @return the latest status
     */
	public Status updateStatus(String theme,String status, double latitude, double longitude, File file, int walkId){
		return new Status(httpSend.postDataWithFile(BaseURL,new PostParameter[]{new PostParameter("theme",theme),
				new PostParameter("status", status),new PostParameter("lat", latitude),new PostParameter("long", longitude),new PostParameter("walkId", walkId) }, file,true));
		
	}
	
	 /**
     * Updates the user's status.
     * The text will be trimmed if the length of the text is exceeding 160 characters.
     * <br>This method calls some address
     *
     * @param theme  
     * @param status    the text of your status update
     * @param locationString the location group 
     * @param File  the file want to be uploaded
     * @return the latest status
     */
	public Status updateStatus(String theme,String status,String locationString, int walkId){
		return new Status(httpSend.postData(BaseURL,new PostParameter[]{new PostParameter("theme",theme),
				new PostParameter("status", status),new PostParameter("locgroup", locationString),new PostParameter("walkId", walkId)},true));
		
	}


	
	
	
	
	
}
